package com.jfeat.am.module.wegou.api.crud;

import com.baomidou.mybatisplus.plugins.Page;
import com.jfeat.am.common.constant.tips.SuccessTip;
import com.jfeat.am.common.constant.tips.Tip;
import com.jfeat.am.module.social.services.crud.service.MemberCareService;
import com.jfeat.am.module.social.services.persistence.model.MemberCare;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * Created by Silent-Y on 2018/2/10.
 */
@RestController
@RequestMapping("/api/membercare")
public class MemberCareEndpoint {

    @Resource
    MemberCareService memberCareService;

    @GetMapping("/{resId}")
    public Tip queryMemberCares(@PathVariable Long resId,
                                Page<MemberCare> page,
                                @RequestParam(name = "pageNum", required = false, defaultValue = "1") Integer pageNum,
                                @RequestParam(name = "pageSize", required = false, defaultValue = "10") Integer pageSize){
        page.setCurrent(pageNum);
        page.setSize(pageSize);
        page.setRecords(memberCareService.queryMemberCareWithUserByResId(page,resId));
        return SuccessTip.create(page);
    }
}
